package proxyTest.cglib;


import net.sf.cglib.proxy.Enhancer;

/**
 * @author zyc
 * @create 2022--05--06 16:31
 */
public class CglibFactory {
    public static Object getProxy(Object obj) {
        Class<?> clazz = obj.getClass();

        Enhancer enhancer = new Enhancer();

        enhancer.setClassLoader(clazz.getClassLoader());

        enhancer.setSuperclass(clazz);

        enhancer.setCallback(new StuMethodInterceptor());

        return enhancer.create();
    }
}
